import axios from 'axios'

const Mock = require('mockjs')
const Random = Mock.Random

Mock.mock('/api/getOrderList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      orderNo: Random.natural(),
      orderTime: Random.date('yyyy-MM-dd hh:mm:ss'),
      nickName: Random.name(),
      contanctPhone: Random.natural(),
      contanctAddress: `${Random.province()}${Random.city()}${Random.county()}`,
      orderPlatform: Random.integer(1, 2),
      orderType: Random.integer(1, 2),
      orderStatus: Random.integer(1, 5),
      detailList: [
        {
          goodsTitle: Random.csentence(10, 20),
          goodsDesc: Random.ctitle(),
          goodsImgUrl: Random.image('60x60', '#894FC4', '#FFF', 'Mock.js')
        }
      ]
    }
    list.push(listObject)
  }
  return {
    data: list
  }
})

Mock.mock('/api/getTagsList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      tag_name: Random.csentence(),
      level: Random.range(1, 5),
      is_show: Random.integer(0, 1),
      sort: Random.integer(0, 9999),
      createdTime: Random.date('yyyy-MM-dd hh:mm:ss')
    }
    list.push(listObject)
  }
  return {
    data: list
  }
})

Mock.mock('/api/getAppraiseList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      goodsName: Random.csentence(5),
      orderNo: Random.natural(),
      nickName: Random.name(),
      contanctPhone: Random.natural(),
      tag_name: Random.csentence(),
      tag_text: Random.csentence(),
      imgList: [
        Random.image('60x60', '#894FC4', '#FFF', 'Mock.js'),
        Random.image('60x60', '#894FC4', '#FFF', 'Mock.js'),
        Random.image('60x60', '#894FC4', '#FFF', 'Mock.js')
      ],
      sort: Random.integer(0, 9999),
      createdTime: Random.date('yyyy-MM-dd hh:mm:ss')
    }
    list.push(listObject)
  }
  return {
    data: list
  }
})

// 订单列表
export function getOrderList() {
  return axios.get('/api/getOrderList').then(res => {
    return res.data.data
  })
}

// 订单标签
export function getTagsList() {
  return axios.get('/api/getTagsList').then(res => {
    return res.data.data
  })
}

// 订单评论
export function getAppraiseList() {
  return axios.get('/api/getAppraiseList').then(res => {
    console.log(res.data.data)
    return res.data.data
  })
}
